<template>
	<view class="myPages"  :style="{paddingTop: `${search.top+search.height+10}px`}">
		<myHeard :search="search" :title="title" @goPath="goBack"></myHeard>
		<view class="myPages__Main">
			<view class="myPages__MainTop">
				已累计推荐: <span>{{total}}</span>个新用户
			</view>
			<view class="myPages__MainItems" v-for="(item,index) in recList" :key="index">
			   <view class="myPages__MainItemsLeft">
				   <image  @click.stop="ff_previewImage(item.avatar)" class="myPages__MainItemsLeftImg" :src="item.avatar"></image>
			   </view>
			   <view class="myPages__MainItemsRight">
				    <view class="myPages__MainItemsRightTop">{{item.nickname}}</view>
				   <view class="myPages__MainItemsRightBottom">{{item.createTime | ff_createTime}}</view>
			   </view>
			</view>
		</view>

	</view>
</template>

<script>
	import myHeard from '@/components/myHeard/index.vue'
	export default {
		components: {
			myHeard
		},
		data() {
			return {
				title: '我的推荐',
				recList: [],
				pageNum:1,
				pageSize:10,
				total: 0
			}
		},
		onLoad(query) {
			// #ifndef H5
			let search = uni.getMenuButtonBoundingClientRect()
			this.$store.commit('updataSearch', search);
			// #endif
			this.initUserWxRecList();
			
			
		},
		onShow() {
			
		},
		computed: {
			search() {
				return this.$store.state.search;
			},

		},
		onReachBottom() {
			this.pageNum++;
			this.initUserWxRecList();
		},
		filters: {
			ff_createTime(date) {
				date = new Date(date)
				const year = date.getFullYear()
				const month = date.getMonth() + 1
				const day = date.getDate()
				const hour = date.getHours()
				const minute = date.getMinutes()
				const second = date.getSeconds()
		
				function formatNumber(n) {
					n = n.toString()
					return n[1] ? n : '0' + n
				}
				return `${year}年${month}月${day}日` + ' ' + `${formatNumber(hour)}:${formatNumber(minute)}`;
			}
		},
		methods: {
			//调用预览图片的方法
			ff_previewImage(myImgs, index = 0) {
				uni.previewImage({
					urls: [myImgs],
					current: index
				})
			},
			initUserWxRecList(){
				
					uni.showLoading({
						title: '加载中',
							mask:true
					});
				this.$api.userWxRecList({pageNum:this.pageNum,pageSize:this.pageSize}).then(res=>{
					if(res.code==200){
						this.total = res.total;
						this.recList = [...this.recList,...res.rows];
						
					}
				})
			},
			goPath(url) {
				uni.navigateTo({
					url
				})
			},
			goBack() {
				uni.navigateBack()
			},
			
		}
	}
</script>

<style scoped lang="scss">
	.myPages {
		min-height: 100vh;
		background-color: #F7F8FC;
		box-sizing: border-box;
		.myPages__MainTop{
			height: 50rpx;
			font-size: 26rpx;
			font-family: 'DIN';
			font-weight: normal;
			line-height: 36rpx;
			color: #2B2B33;
			opacity: 1;
			span{
				    font-size: 43rpx;
				    margin: 0 4rpx;
					color: #F0414D;
			}
		}
		// <view class="myPages__MainItems" v-for="index in 8" :key="index">
		//    <view class="myPages__MainItemsLeft">
		// 	   <image class="myPages__MainItemsLeftImg" src="/static/images/admin.png"></image>
		//    </view>
		//    <view class="myPages__MainItemsRight">
		// 	    <view class="myPages__MainItemsRightTop">小刘刘刘</view>
		// 	   <view class="myPages__MainItemsRightBottom">2021年4月7日 09:00</view>
		//    </view>
		// </view>
		.myPages__MainItemsLeft{
			width: 100rpx;
			height: 100rpx;
			border-radius: 20rpx;
			overflow: hidden;
		}
		.myPages__MainItemsRight{
			margin-left: 32rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
		}
		.myPages__MainItemsRightTop{
			height: 40rpx;
			font-size: 28rpx;
			font-family: 'DIN';
			font-weight: normal;
			line-height: 40rpx;
			color: #2B2B33;
			opacity: 1;
		}
		.myPages__MainItemsRightBottom{
			height: 34rpx;
			font-size: 24rpx;
			font-family: 'DIN';
			font-weight: normal;
			line-height: 34rpx;
			color: #868896;
		}
		.myPages__MainItemsLeftImg{
			width: 100%;
			height: 100%;
		}
		.myPages__Main{
			box-sizing: border-box;
			width: 100%;
			padding: 32rpx;
			.myPages__MainItems{
				display: flex;
				width: 100%;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 40rpx rgba(228, 228, 245, 0.4);
				opacity: 1;
				border-radius: 40rpx;
				padding: 32rpx;
				box-sizing: border-box;
				margin-bottom: 20rpx;
			}
		}
		.myPages__MainItemsTopLeft{
			display: flex;
			align-items: center;
			span{
				display: inline-block;
				height: 40rpx;
				font-size: 28rpx;
				font-family: 'DIN';
				font-weight: normal;
				line-height: 40rpx;
				color: #2B2B33;
				margin-right: 14rpx;
			}
			span:nth-child(3){
			    width: 64rpx;
			    height: 35rpx;
			    background: rgba(240, 65, 77, 0.02);
			    border: 2rpx solid #F0414D;
			    opacity: 1;
			    border-radius: 8rpx;
			    font-size: 20rpx;
			    font-family: 'DIN';
			    font-weight: normal;
			    box-sizing: border-box;
			    line-height: 35rpx;
			    color: #F0414D;
			    opacity: 1;
			    text-align: center;
			}
		}
		.myPages__MainItemsTop{
			display: flex;
			justify-content: space-between;
			}
			.myPages__MainItemsTopRight{
				height: 40rpx;
				font-size: 28rpx;
				font-family: 'DIN';
				font-weight: normal;
				line-height: 40rpx;
				color: #2B2B33;
			}
			.myPages__MainItemsBottom{
				margin-top: 8rpx;
				height: 34rpx;
				font-size: 24rpx;
				font-family: 'DIN';
				font-weight: normal;
				line-height: 34rpx;
				color: #868896;
			}
		
	
	}
</style>
